const url = 'https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg'
const url2 = 'https://www.baidu.com/img/bd_logo1.png'
function loadImg(src) {
  return new Promise((resolve, reject) => {
    console.log('start')
    const img = document.createElement('img')
    img.onload = () => {
      console.log('loaded')
      resolve(img)
    }
    img.onerror = () => {
      resolve(new Error(`图片加载失败${src}`))
    }
    img.src = src
    console.log('end')
  })
}

loadImg(url)
.then(img => {
  document.body.appendChild(img)
  console.log(img.height)
  return loadImg(url2)
})
.then(img => {
  document.body.appendChild(img)
  console.log(img.height)
})
.catch(err => console.log(err))